<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box {
      position: relative;
      height: 300px;
      background-color: rgb(242, 245, 249);
    }

    .box a {
      display: none;
      position: absolute;
      right: 20px;
      top: 10px;
      border-radius: 3px;
      padding: 2px 5px;
      font-size: 12px;
      /* color: rgb(242, 245, 249); */
      text-decoration: none;
    }

    .box:hover a {
      display: block;
      background-color: white;
      color: #666;
    }
  </style>
</head>

<body>
  <div class="box">
    <a href="#">登录后复制</a>
    12223
  </div>
</body>
<sCript>
  function fn1(x) {
    return x + 1
  }

  function fn2(x) {
    return x + 2
  }

  function fn3(x) {
    return x + 3
  }

  function fn4(x) {
    return x + 4
  }
  const a = ass(fn1, fn2, fn3, fn4)
  console.log(a(1))

  function ass(...fn) {
    return fn.reduce((pre, cur) => (...args) => {
      console.log(args)
      console.log(cur)
      return pre(cur(...args))
    })
  }

  // const aryTmp = [2,34,5,45,6,6,55,32,1]
  // aryTmp.reduce((pre, cur, index, ary) => {
  //   // console.log(pre)
  //   // console.log(index)
  //   return pre
  // })

  var prices = [{price: 23}, {price: 45}, {price: 56}]
  var rates = {
    us: '6.5',
    eu: '7.5',
  }
  var initialState = {usTotal:0, euTotal: 0}
  var res = prices.reduce((accumulator, cur1) =>
    Object.keys(rates).reduce((prev2, cur2) => {
      console.log(accumulator, cur1, prev2, cur2)
      // console.log(prev2, cur2)
      accumulator[`${cur2}Total`] += cur1.price * rates[cur2]
      return accumulator
    }, {}), initialState)

  var manageReducers = function() {
    return function(state, item) {
      return Object.keys(rates).reduce((nextState, key) => {
        state[`${key}Total`] += item.price * rates[key]
        return state
      }, {})
    }
  }
  var res1 = prices.reduce(manageReducers(), initialState)

  // console.log(res)
  // console.log(res1)


  // var result = [
  //   { subject: 'math', score: 88 },
  //   { subject: 'chinese', score: 95 },
  //   { subject: 'english', score: 80 }
  // ]
  // var dis = {
  //     math: 0.5,
  //     chinese: 0.3,
  //     english: 0.2
  // }
  // var sum = result.reduce((pre, cur) => 
  //  pre + cur.score * dis[cur.subject]
  // , 0)
  // console.log(sum)

  // var streams = [{name: '技术', id: 1}, {name: '设计', id: 2}]
  // var obj = streams.reduce((accumulator, cur) => {
  //   accumulator[cur.id] = cur
  //   return accumulator
  // }, {})
  // console.log(obj)

  // var arr = aryTmp.reduce((pre, cur) => {
  //   pre.push(cur * cur)
  //   return pre
  // }, [])
  // console.log(arr)

  // var newArr = aryTmp.reduce((pre, cur) => {
  //   pre.indexOf(cur) === -1 && pre.push(cur)
  //   return pre
  // }, [])

  // console.log(newArr)
  
  // const str = 'sfhjasfjgfasjuwqrqadqeiqsajsdaiwqdaklldflas-cmxzmnha'
  // const res = str.split('').reduce((pre, cur) => {
    //   pre[cur] ? pre[cur]++ : pre[cur] = 1
    //   return pre
  // }, {})
  // console.log(res)
</sCript>

</html>